package com.df.hotfix.scripts;

import com.df.hotfix.scripts.impl.DemoScript;

import java.util.concurrent.ConcurrentHashMap;

public class ScriptManager {

    private enum Single {
        INSTANCE;
        private ScriptManager scriptManager;

        Single() {
            scriptManager = new ScriptManager();
        }
    }

    private ScriptManager() {

    }

    public static ScriptManager instance() {
        return Single.INSTANCE.scriptManager;
    }


    private ConcurrentHashMap<String,IScript> scripts = new ConcurrentHashMap<>();

    public void loadScripts(){
        scripts.put(DemoScript.class.getName(),new DemoScript());
    }

    public void replateScript(String key,IScript value){
        scripts.put(key,value);
    }

    public IScript getScript(String key){
        return scripts.get(key);
    }
}
